/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PropertyRental.ejb.beans;

import PropertyRental.ejb.persistence.Account;
import javax.ejb.EJB;
import javax.ejb.Stateful;
import javax.ejb.LocalBean;

/**
 *
 * @author Bast
 */
@Stateful
@LocalBean
public class LoginEJB {
    @EJB
    AccountFacade accountEJB;

    private Account acc;

    public Account getAccount() {
        return acc;
    }

    public LoginEJB(){
        acc = null;
    }

    public boolean login(String username, String password){
        Account acc = accountEJB.findByUsernamePassword(username, password);
        if (acc != null){
            this.acc = acc;
            return true;
        }
        else
            return false;
    }

    public void logout(){
       this.acc = null;
    }

    public void delete(){
        accountEJB.deleteAccount(acc);
    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    
}
